// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	/* 平台功能接口开始 */
	const signIn = (type, params = {}) => vm.$u.post(
		'/api/oauth/Login?client_id=admin&client_secret=123456&scope=all&grant_type=' + type, params)
	const signUp = (params = {}) => vm.$u.post('/api/oauth/register', params)
	const sendLoginCaptcha = (params = {
		phone: '',
		uuid: ''
	}) => vm.$u.post('/api/oauth/sms/sendLoginCaptcha', params)
	const getBanner = () => vm.$u.get(
		`/api/visualdev/OnlineDev/ce275615b1214760b7201310f0c2d85f/List?currentPage=1&pageSize=5&sort=asc&sidx=sort_code&json=%7B%22enabled_mark%22%3A%20'1'%7D`, {}
	)
	const getNews = () => vm.$u.get(
		`/api/visualdev/OnlineDev/8bb0758b60d3424cbdaa30ca0f94f563/List?n=1622463964&currentPage=1&pageSize=20&sort=asc&sidx=sort_code&json=%7B%22enabled_mark%22%3A%20'1'%7D`, {}
	)
	const getNoticeList = (params = {}) => vm.$u.get('/api/system/Message', params)
	const getNotice = (id) => vm.$u.get('/api/system/Message/ReadInfo/' + id)
	const getMessage = (params = {
		pageSize: 20,
		currentPage: 1,
		type: '2'
	}) => vm.$u.get('/api/system/Message', params)

	const getUsersAll = () => vm.$u.get('/api/system/Permission/Users/All')
	const getOrgUsers = (params = {
		orgId: -1
	}) => vm.$u.get('/api/system/mobile/addressbook/organizeUserSelector', params)
	const recentContact = () => vm.$u.get('/api/system/mobile/addressbook/recentContact')
	const addRecent = (userId) => vm.$u.post(`/api/system/mobile/addressbook/recentContact/${userId}`)
	const findFavoriteContact = () => vm.$u.get('/api/system/mobile/addressbook/findFavoriteContact')
	const setFavorite = (userId) => vm.$u.post(`/api/system/mobile/addressbook/favorite/${userId}`)
	const getCurrentUser = () => vm.$u.get('/api/oauth/App/CurrentUser?n=' + (new Date() - 0))
	const findParentOrg = (params = {
		orgId: -1
	}) => vm.$u.get('/api/system/Permission/Organize/findParentOrg', params)
	const getContactsInfo = (params = {
		id: ''
	}) => vm.$u.get('/api/system/Permission/Users/getContactsInfo', params)
	const getManagerChain = (params = {
		userId: ''
	}) => vm.$u.get('/api/system/Permission/Users/getManagerChain', params)
	const findSubUser = (params = {
		userId: ''
	}) => vm.$u.get('/api/system/Permission/Users/findSubUser', params)
	const searchUser = (params = {}) => vm.$u.post('/api/system/Permission/Users/search', params)
	// 工作流表单接口开始
	const getFlowEngine = (fid) => vm.$u.get(`/api/workflow/Engine/FlowEngine/${fid}`)
	const postFlowTask = (params = {}) => vm.$u.post('/api/workflow/Engine/FlowTask', params)
	const putFlowTask = (fid, params = {}) => vm.$u.put('/api/workflow/Engine/FlowTask/' + fid, params)
	const getFlowTask = (fid) => vm.$u.get('/api/workflow/Engine/FlowTask/' + fid)
	const getFlowLaunch = (params = {
		pageSize: 10,
		currentPage: 1
	}) => vm.$u.get('/api/workflow/Engine/FlowLaunch', params)
	const getFlowBefore = (fid, nId) => vm.$u.get(`/api/workflow/Engine/FlowBefore/${fid}?taskNodeId=${nId}`)
	const getFlowBeforeList = (type, params = {}) => vm.$u.get('/api/workflow/Engine/FlowBefore/List/' + type,
		params)
	// 撤回接口
	const putWithdraw = (fid, params = {}) => vm.$u.put('/api/workflow/Engine/FlowLaunch/' + fid +
		'/Actions/Withdraw', params)
	// 催办接口
	const postPrees = (fid) => vm.$u.post('/api/workflow/Engine/FlowLaunch/Press/' + fid)
	// 拒绝接口
	const postReject = (fid, params = {}) => vm.$u.post('/api/workflow/Engine/FlowBefore/Reject/' + fid, params)
	// 通过接口
	const postAudit = (fid, params = {}) => vm.$u.post('/api/workflow/Engine/FlowBefore/Audit/' + fid, params)
	// 转办接口
	const postTransfer = (tid, params = {}) => vm.$u.post('/api/workflow/Engine/FlowBefore/Transfer/' + tid, params)
	/* 平台功能接口结束 */
	/* 日程接口开始 */
	const findScheduleList = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/findScheduleList', params)
	const getByDate = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/getByDate', params)
	const SelectorForSch = () => vm.$u.get('/api/system/Permission/Organize/Department/SelectorForSch')
	const favoriteContacts = (params = {
		data: ''
	}) => vm.$u.post('/api/schedule/mobile/schedule/favoriteContacts', params)
	const scheduleAdd = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/add', params)
	const scheduleDetail = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/detail', params)
	const scheduleRemove = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/remove', params)
	const acceptOrRefuse = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/acceptOrRefuse', params)
	const addFeedBack = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/addFeedBack', params)
	const setDone = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/setDone', params)
	const removeFeedBack = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/removeFeedBack', params)
	const addSummry = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/addSummry', params)
	const scheduleEdit = (params = {}) => vm.$u.post('/api/schedule/mobile/schedule/edit', params)

	/* 日程接口结束 */
	/* 打卡接口开始 */
	const clockInUserInfo = () => vm.$u.get('/api/attendance/mobile/clockIn/userInfo')
	const clockIn = (params = {}) => vm.$u.post('/api/attendance/mobile/clockIn', params)
	/* 打卡接口结束 */
	/* 爱森接口开始 */
	// 种树
	const forestTree = (params = {}) => vm.$u.get('api/forest/ForestTree', params)
	// 种树详情
	const forestTreeDetail = (params = {
		id: ''
	}) => vm.$u.get(`api/forest/ForestTree/plant/${params.id}`)
	// 申请种树
	const forestTreeApplay = (params = {
		id: ''
	}) => vm.$u.post(`api/forest/ForestTree/plant/${params.id}`)
	// 守护详情
	const forestTreeGuard = (params = {
		id: ''
	}) => vm.$u.get(`api/forest/ForestTree/guard/${params.id}`)
	// 守护树木
	const applayTreeGuard = (params = {
		id: ''
	}) => vm.$u.post(`api/forest/ForestTree/guard/${params.id}`)
	// 植树证书
	const forestMedal = (params = {
		id: ''
	}) => vm.$u.post(`api/forest/ForestTree/plantCertificate/${params.id}`)
	// 守护证书
	const guardCertificate = (params = {
		id: ''
	}) => vm.$u.post(`api/forest/ForestTree/guardCertificate/${params.id}`)
	// 成就植树证书
	const medalPlant = (params = {
		id: ''
	}) => vm.$u.get(`api/forest/ForestMedal/plant/${params.id}`)
	// 成就守护证书
	const medalGuard = (params = {
		id: ''
	}) => vm.$u.get(`api/forest/ForestMedal/guard/${params.id}`)
	//成就馆
	const forestMedalList = () => vm.$u.get(`api/forest/ForestMedal`)
	//植树勋章
	const plantMedal = () => vm.$u.get(`api/forest/ForestMedal/plantMedal`)
	//守护勋章
	const guardMedal = () => vm.$u.get(`api/forest/ForestMedal/guardMedal`)
	//进入园林
	const gardenInfo = (params = {
		id: ''
	}) => vm.$u.get(`api/forest/ForestMedal/garden/${params.id}`)
	//园林动态
	const gardenTrends = (params = {
		id: ''
	}) => vm.$u.get(`api/forest/ForestMedal/gardenTrends/${params.id}`)
	//成员总能量
	const userEnergySort = (params = {
		paramType: 1,
		gainDataCompany: "",
		currentPage: 1,
		pageSize: 20
	}) => vm.$u.get(
		`api/forest/forestUserInfoSort/userEnergySort?paramType=${params.paramType}&gainDataCompany=${params.gainDataCompany}&currentPage=${params.currentPage}&pageSize=${params.pageSize}`
	)
	//成员贡献能量
	const userUseEnergySort = () => vm.$u.get(`api/forest/forestUserInfoSort/userUseEnergySort`)
	//成员周排行榜
	const userWeekEnergySort = () => vm.$u.get(`api/forest/forestUserInfoSort/userWeekEnergySort`)
	//每日步数
	const eayEnergy = (params = {
		type: 1
	}) => vm.$u.get(`api/forest/PersonalFootprint/EayEnergy/${params.type}`)
	//个人累计步数
	const yearEnergy = (params = {
		type: 2,
		year: ""
	}) => vm.$u.get(`api/forest/PersonalFootprint/YearEnergy?type=${params.type}&year=${params.year}`)
	//能量获取详情
	const gainEnergyDetail = () => vm.$u.get(`api/forest/Garden/gainEnergyDetail`)
	//获取排班
	const getScheduling = () => vm.$u.get(`api/forest/getScheduling`)
	//组织排行榜
	const energySortList = (params = {}) => vm.$u.get(`api/forest//forestCompany/companyRank`, params)

	const getPersonalGarden = () => vm.$u.get('/api/forest/Garden/PersonalGarden')

	const memberGarden = (id) => vm.$u.get('/api/forest/Garden/gainEnergy/' + id)

	const getMemberGarden = (id) => vm.$u.get('/api/forest/Garden/MemberGarden/' + id)

	const getIrrigate = (params = {}) => vm.$u.post('/api/forest/Garden/irrigate', params)

	const getCompanyEnergyByUserId = () => vm.$u.get(
		'/api/forest/forestCompanyEnergyInfoSort/companyEnergyByUserId')
	const getEnergySortList = (params = {}) => vm.$u.get('/api/forest/forestCompanyEnergyInfoSort/energySortList/',
		params)
	const forestPunchRecord = (params = {}) => vm.$u.post('/api/forest/forestPunchRecord', params)

	const getForestAuthorize = () => vm.$u.post('/api/forest/ForestAuthorize')

	const forestAuthorize = () => vm.$u.get('/api/forest/ForestAuthorize')

	const companyInfo = () => vm.$u.get('/api/forest/forestCompany/companyInfo')

	const personalInfo = (params = {}) => vm.$u.post('/api/forest/forestCompany/personalInfo', params)

	const personalRank = (params = {}) => vm.$u.post('/api/forest/forestCompany/personalRank', params)
	
	const forestMessage = (params = {}) => vm.$u.get(`/api/forest/Garden/message/${params.id}`)
	//资产接口
	//资产区域分布统计
	const statisticsArea = (params = {}) => vm.$u.post('/api/asset/mobile/asset/statisticsArea', params)
	//资产状态列表
	const statisticsAssetStatus = (params = {}) => vm.$u.post('/api/asset/mobile/asset/statisticsAssetStatus',
		params)
	//资产价值列表
	const statisticsAssetValue = (params = {}) => vm.$u.post('/api/asset/mobile/asset/statisticsAssetValue', params)
	//资产详情列表
	const statisticsAssetInfo = (params = {}) => vm.$u.post('/api/asset/mobile/asset/statisticsAssetInfo', params)
	//地图
	const getProvinceList = (params = {}) => vm.$u.post('/api/asset/mobile/asset/getProvinceList', params)
	//公司
	const getCompanyList = () => vm.$u.post('/api/asset/mobile/asset/getCompanyList')
	//资产详情
	const getMobileAssetInfo = (params = {}) => vm.$u.post('/api/asset/mobile/asset/getMobileAssetInfo', params)
	//操作关注
	const setAttention = (params = {}) => vm.$u.post('/api/asset/mobile/asset/setAttention', params)
	//我的
	const getUserInfo = () => vm.$u.post('/api/asset/mobile/asset/user/getUserInfo')
	const getUserAssetList = () => vm.$u.post('/api/asset/mobile/asset/user/getUserAssetList')
	const getUserAttentionList = () => vm.$u.post('/api/asset/mobile/asset/user/getUserAttentionList')

	/* 大宗接口开始 */
	//可用天数及总资金占用
	const requestDaysAndFunds = () => vm.$u.get('/api/bulk/mobile/materialWarning/daysAndFunds')
	//获取物料组列表及预警标识_物料名称tab数组
	const requestGroupList = () => vm.$u.get('/api/bulk/mobile/materialWarning/groupList')
	//获取柱状图数据
	const requestStockInfo = (pkid) => vm.$u.get('/api/bulk/mobile/materialWarning/stockInfo/' + pkid)
	//获取港口物料列表
	// portPkid:港口id,不传则返回默认港口的物料列表
	// keywords：模糊搜索关键字
	// baseMaterialPkid：基础物料id
	// currentPage: 请求页码
	const requestMateriaList = (params) => vm.$u.get('/api/bulk/mobile/purchasingDecision/societyList?portPkid=' +
		params.portPkid + '&baseMaterialPkid=' + params.baseMaterialPkid + '&keywords=' + params.keywords +
		'&currentPage=' + params.currentPage + '&pageSize=' + params.pageSize)
	//获取物料类型列表
	const requesMaterialTypeList = () => vm.$u.get('/api/bulk/mobile/materialGroup')
	// 获取默认港口
	const requestDefaultPort = () => vm.$u.get('/api/bulk/mobile/defaultPort')
	//获取港口列表
	//name: 搜索关键字
	const rerquesPortList = (name) => vm.$u.get('/api/bulk/mobile/portList?name=' + name)
	//查询折线图数据
	const requestLineData = (params) => vm.$u.post('/api/bulk/mobile/trend', params)
	//查询近两天所有的订单物料
	const requestNearlyTwoDaysOrder = () => vm.$u.get('/api/bulk/mobile/trend/nearlyTwoDaysOrder')
	//获取所有基础物料
	const requestAllMaterial = () => vm.$u.get('/api/bulk/mobile/trend/allMaterial')
	//查询采购订单量饼图数据
	const requestPieData = (params) => vm.$u.post('/api/bulk/mobile/trend/pieChart', params)
	//请求近期价格趋势图
	const requstPriceLineAndChart = (params) => vm.$u.post('/api/bulk/mobile/trend/lineAndKChart', params)
	//请求物料列表
	// currentPage: 请求页码
	// materialName：搜索字段
	// pageSize：每页数量
	const rerquesMaterialList = (params) => vm.$u.get('/api/bulk/mobile/trend/orderList?materialName=' + params
		.materialName + '&currentPage=' + params.currentPage + '&pageSize=' + params.pageSize)
	//请求订单列表
	// currentPage: 请求页码
	// baseMaterialId：基础物料id
	// pageSize：每页数量
	const requestOrderList = (params) => vm.$u.get('/api/bulk/mobile/trend/orderMaterialList?baseMaterialId=' +
		params.baseMaterialId + '&currentPage=' + params.currentPage + '&pageSize=' + params.pageSize)
	//获取物料详情
	const requestMaterialInfo = (baseMaterialPkid) => vm.$u.get('/api/bulk/mobile/materialWarning/materialInfo/' +
		baseMaterialPkid)
	//请求近期价格趋势图
	const requestLineChart = (params) => vm.$u.post('/api/bulk/mobile/materialWarning/lineChart', params)
	//获取物料详情
	const requestMaterialInfoByPkid = (pkid) => vm.$u.get('/api/bulk/mobile/purchasingDecision/materialInfo/' + pkid)
	//获取订单物料详情
	const requestOrderMaterialInfoByPkid = (pkid) => vm.$u.get('/api/bulk/mobile/trend/orderMaterialInfo/' + pkid)
	/* 大宗接口结束 */


	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		signIn,
		signUp,
		sendLoginCaptcha,
		getBanner,
		getNews,
		getNoticeList,
		getUsersAll,
		getOrgUsers,
		getCurrentUser,
		findParentOrg,
		getContactsInfo,
		getManagerChain,
		findSubUser,
		getNotice,
		searchUser,
		findFavoriteContact,
		setFavorite,
		recentContact,
		addRecent,
		getMessage,
		getFlowEngine,
		postFlowTask,
		putFlowTask,
		getFlowLaunch,
		getFlowTask,
		getFlowBefore,
		putWithdraw,
		postPrees,
		getFlowBeforeList,
		postReject,
		postAudit,
		postTransfer,
		/*日程接口开始*/
		findScheduleList,
		getByDate,
		SelectorForSch,
		favoriteContacts,
		scheduleAdd,
		scheduleRemove,
		scheduleDetail,
		acceptOrRefuse,
		addFeedBack,
		setDone,
		removeFeedBack,
		addSummry,
		scheduleEdit,
		/*日程接口结束*/
		/*打卡接口开始*/
		clockInUserInfo,
		clockIn,
		/*爱森接口开始*/
		getPersonalGarden,
		memberGarden,
		userWeekEnergySort,
		userWeekEnergySort,
		getMemberGarden,
		getIrrigate,
		getCompanyEnergyByUserId,
		getEnergySortList,
		forestTree,
		forestTreeDetail,
		forestTreeApplay,
		forestTreeGuard,
		applayTreeGuard,
		forestMedal,
		guardCertificate,
		forestMedalList,
		plantMedal,
		guardMedal,
		gardenInfo,
		gardenTrends,
		userUseEnergySort,
		medalPlant,
		medalGuard,
		eayEnergy,
		yearEnergy,
		gainEnergyDetail,
		userEnergySort,
		energySortList,
		getScheduling,
		forestAuthorize,
		forestPunchRecord,
		getForestAuthorize,
		companyInfo,
		personalInfo,
		personalRank,
		forestMessage,
		/*爱森接口结束*/
		/*泛资产接口开始*/
		statisticsArea,
		statisticsAssetStatus,
		statisticsAssetValue,
		statisticsAssetInfo,
		getProvinceList,
		getCompanyList,
		getMobileAssetInfo,
		getUserInfo,
		getUserAssetList,
		getUserAttentionList,
		setAttention,
		/*泛资产接口结束*/

		/*大宗接口开始*/
		requestDaysAndFunds,
		requestGroupList,
		requestStockInfo,
		requestMateriaList,
		requesMaterialTypeList,
		requestDefaultPort,
		rerquesPortList,
		requestLineData,
		requestNearlyTwoDaysOrder,
		requestAllMaterial,
		requestPieData,
		requstPriceLineAndChart,
		requestOrderList,
		requestMaterialInfo,
		requestMaterialInfoByPkid,
		rerquesMaterialList,
		requestLineChart,
		requestOrderMaterialInfoByPkid,
		/*大宗接口结束*/
	}
}

export default {
	install
}
